package com.xlh.server.protocol.support.json;

import com.xlh.Utils.GsonManager;
import com.xlh.bean.ProtocolObject.HpInfo;
import com.xlh.interf.IActivity;
import com.xlh.interf.ITakeMessage;
import com.xlh.outside.R;

/**
 * Created by mike@Q184377367 on 2018/7/2.
 */

public class HPServer implements ITakeMessage {

    private IActivity atv;
    private String hasType = "hpInfo";
    private HpInfo protccoObj;
    public HPServer(IActivity atv){
        this.atv = atv;


    }

    @Override
    public void takeMessage(String t,String s){

        if(!t.equals(this.hasType)) return;

        protccoObj =  GsonManager.gsmgr.jsonToAnyObject(s, HpInfo.class);

        if(protccoObj==null) return;

        final HPServer me = this;

        this.atv.getActivity().getUserFg().screenWidth = this.atv.getActivity().getApp().getWndWidth();

        this.atv.getActivity().getUserFg().dealDatas(protccoObj);
        if(  !this.atv.getActivity().getUserFg().isSerColored() ){
            this.atv.getActivity().getFragmentManager().beginTransaction().replace(R.id.mUserGroup, this.atv.getActivity().getUserFg()).commitAllowingStateLoss();
        }





    }

    @Override
    public boolean takeMessage(String s) {
        return false;
    }

    @Override
    public void init() {

    }

    @Override
    public void atViewLoadAfterInit() {

    }

}
